*** Settings ***
Library           FN

*** Test Cases ***
2.1 已登录用户存在一个配置，通过appCode进行查询，返回对应的配置
    Init Step
    ${uri}    Set Variable    /v1/access/page/redirect
    ${appcode}    Get UUID
    ${areacode}    Set Variable    hb
    ${businessType}    Set Variable    order
    ${terminalType}    Set Variable    web
    ${outBusinessId}    Set Variable
    ${callback}    Set Bool Variable    ${True}
    ${callbackAddress}    Set Variable
    ${address}    Set Variable    http://baidu.com?a=1
    ${new_bgw_sql}    Create A Bgw Config    ${appcode}    ${areacode}    ${businessType}    ${terminalType}    ${address}
    Mysql Step
    Connect To Database    pymysql    ${BGW_DB_URL}    ${BGW_DB_ALIAS}
    Execute Sql String    ${BGW_DB_ALIAS}    delete from bgw_business_access_config_info where appcode = '${appcode}'    ${DB_OP_TYPE_DELETE}
    Execute Sql String    ${BGW_DB_ALIAS}    ${new_bgw_sql}    ${DB_OP_TYPE_INSERT}
    Doing Step
    ${post_data}    Create Dictionary
    Set To Dictionary    ${post_data}    appcode    ${appcode}
    Set To Dictionary    ${post_data}    areacode    ${areacode}
    Set To Dictionary    ${post_data}    businessType    ${businessType}
    Set To Dictionary    ${post_data}    terminalType    ${terminalType}
    Set To Dictionary    ${post_data}    outBusinessId    ${outBusinessId}
    Set To Dictionary    ${post_data}    callback    ${callback}
    Set To Dictionary    ${post_data}    callbackAddress    ${callbackAddress}
    ${cookies}    Get Http Cookie    ${BOSS_HOST}    ${BOSS_LOGIN_URI}    ${BOSS_USER_ADMIN}
    ${resp}    Http Post    ${BGW_HOST}    ${uri}    ${post_data}    json    ${cookies}
    Check Step
    ${accessId}    Set Variable    ${resp['data']['accessId']}
    Equal As String    ${resp['data']['address']}    ${address}&accessId=${accessId}
    ${access_info_result}    Query    ${BGW_DB_ALIAS}    select business_access_info from bgw_business_access_info where business_access_id = '${accessId}' and appcode = '${appcode}';
    Set To Dictionary    ${post_data}    token    ${cookies['sso-epctoken']}
    AES Decrypt    ${cookies['sso-epctoken']}
    Equal As Json String    ${access_info_result[0]['business_access_info']}    ${post_data}    ${True}
    Close Step
    Close Database    ${BGW_DB_ALIAS}
